package com.showcai.service.impl;

import com.showcai.module.Order;
import com.showcai.module.PayParameter;
import com.showcai.myRunTime.MyRunTimeExcption;
import com.showcai.service.OrderService;
import com.showcai.service.PayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * Created by Baggio on 2017-3-19.
 */
@Service("groupPayService")
public class GroupPayServiceImpl extends PayBase implements PayService {

    @Autowired
    private OrderService orderService;


    @Override
    public String getPayParameterStr(Long orderId, Integer price, String remoteAddr, Map<String, String> payParametersMap) {

        String requestString = "";
        return requestString;
    }

    @Override
    public PayParameter pay(Long orderId, Integer price, String dataString, String ticket) throws Exception {
        PayParameter payParameter = new PayParameter();
        Order order = orderService.getOrderById(orderId);
        try {

        } catch (MyRunTimeExcption e) {
            logger.warn("【" + e.getMessage() + "。。。。。。】");
            throw new MyRunTimeExcption(e.getMessage());
        }
        return null;
    }


    @Override
    public Map<String, String> notification(Map<String, String> map) {
        logger.info("【支付回调。。。。。。】");

        String orderIdStr=map.get("orderId");
        String payModeSr=map.get("payMode");

        Long orderId=Long.parseLong(orderIdStr);
        Byte payMode=Byte.parseByte(payModeSr);
        super.payin(orderId,null,payMode);

        return null;
    }

    @Override
    public PayParameter refund(Order order, Integer price) {
        return null;
    }
}
